<?php

class Soul_Template_Html_Form_Textarea extends Soul_Template_Html_Form_Input {

    private $_rows = 3;
    private $_columns = 5;
    
    public function __construct() {
        $this->templateName = 'form/textarea';
        $this->addClass('input', 'textarea');
    }

    public function setRows($row){
        $this->_rows = $row;
        return $this;
    }

    public function getRows(){
        return $this->_rows;
    }
    
    public function setColumns($value){
        $this->_columns = $value;
        return $this;
    }

    public function getColumns(){
        return $this->_columns;
    }    

    public function getType() {
        return 'textArea';
    }

    protected function renderReadonly() {
        return '<span class="readonly">'.nl2br($this->getValue()).'&nbsp;</span>';
    }

    protected function renderEditable() {
        if (!$this->getEnabled()) {
            $this->addClass('disabled');
        }
        $this->setAttribute('id', $this->getId())
             ->setAttribute('name', $this->getName())
             ->setAttribute('rows', $this->getRows())           ;
        if (!$this->getEnabled()) {
            $this->setAttribute('disabled', 'disabled');
        }
        return '<textarea ' . $this->getAttributeHtml() . '>' . $this->getValue() . '</textarea>';
    }

}